
// Wire up JQUery validation
$().ready(function() {
    InitializeValidationMethods();
    $.metadata.setType("attr", "validate");
    $('#aspnetForm').validate({ onsubmit: false });
});

function InitializeValidationMethods() {
    // Add additional validation rules
    $.validator.addMethod("integer", function(value, element, param) {
        if (value == '')
            return true;
        return value.match(/^[-+]?\d+$/);
    });
    $.validator.addMethod("militaryTime", function(value, element, param) {
        if (value == '')
            return true;
        return value.match(/^([0-1][0-9]|[2][0-3])(:)*([0-5][0-9])$/);
    });
    $.validator.addMethod("USphone", function(value, element, param) {
        if (value == '')
            return true;
        return value.match(/^[2-9]\d{2}[- ]?\d{3}[- ]?\d{4}$/);
    });
    $.validator.addMethod("USdollar", function(value, element, param) {
        if (value == '')
            return true;
        return value.match(/^\$?\d+(\.\d\d)?$/);
    });
}

function isFormValid(sender) {
    return $("#aspnetForm").valid();
}

function isModuleValid(sender) {
    var modFrame = $(sender).closest('.moduleFrame');
    var elements = modFrame.find('[validate]');
    return $("#aspnetForm").valid(elements);
}